/******************************************************************************
** 
**	File name:		ctoasm.inc
**	
**	Description:	RTOS internal header. Defines aliases for ATmega & ATxmega 
**					MCU registers as defined in the following table:
**
** 	--------+-------+-------+-------+-------+
** 			| TMP	| WXYZ	| p1/p2	| r1l/h	|
** 	--------+-------+-------+-------+-------+
** 	 R18	| tmp0  | 		|		|		|
** 	 R19	| tmp1	|		|		|		|
** 	 R20	| tmp2	|		|		|		|
**	 R21	| tmp3	|		|		|		|
**	 R22	|		|		| p2l	|		|
** 	 R23	|		|		| p2h	|		|
**	 R24	|		| Wl	| p1l	| r1l	|
**	 R25	|		| Wh	| p1h	| r1h	|
** 	 R26	| tmp4	| Xl	| 		|		|
**	 R27	| tmp5	| Xh	|		|		|
**	 R28	|		| Yl	|		|		|
**	 R29	|		| Yh	|		|		|
**	 R30	|		| Zl	|		|		|
**	 R31	|		| Zh	|		|		|
** 	--------+-------+-------+-------+-------+
**
*******************************************************************************
** 						GNU GCC CALLING CONVENTIONS
*******************************************************************************
**
** Data types:
** ===========
** char 		is 8 bits, 
** int 			is 16 bits, 
** long 		is 32 bits, 
** long long 	is 64 bits, 
** float and double are 32 bits (this is the only supported floating point 
** format), 
** pointers 	are 16 bits (function pointers are word addresses, to 
** allow addressing up to 128K program memory space). 
**
** NOTE: There is a -mint8 option (see Options for the C compiler avr-gcc) to make int 8 bits, 
** but that is not supported by avr-libc and violates C standards (int must be at least 16 bits). 
** It may be removed in a future release.
**
** Call-used registers (r18-r27, r30-r31):
** =======================================
** May be allocated by gcc for local data. You may use them freely in assembler subroutines. 
** Calling C subroutines can clobber any of them - the caller is responsible for saving and 
** restoring.
** 
** Call-saved registers (r2-r17, r28-r29):
** =======================================
** May be allocated by gcc for local data. Calling C subroutines leaves them unchanged. 
** Assembler subroutines are responsible for saving and restoring these registers, if changed. 
** r29:r28 (Y pointer) is used as a frame pointer (points to local data on stack) if necessary. 
** The requirement for the caller to save/preserve the contents of these registers even applies 
** in situations where the compiler assigns them for argument passing.
**
** Fixed registers (r0, r1):
** =========================
** Never allocated by gcc for local data, but often used for fixed purposes:
** r0 - temporary register, can be clobbered by any C code (except interrupt handlers which save it), 
** 		may be used to remember something for a while within one piece of assembler code
** r1 - assumed to be always zero in any C code, may be used to remember something for a while 
**		within one piece of assembler code, but must then be cleared after use (clr r1). This 
**		includes any use of the [f]mul[s[u]] instructions, which return their result in r1:r0. 
**		Interrupt handlers save and clear r1 on entry, and restore r1 on exit (in case it was non-zero).
** 
** Function call conventions:
** ==========================
** Arguments - allocated left to right, r25 to r8. All arguments are aligned to start in even-numbered registers (odd-sized arguments, including char, have one free register above them). This allows making better use of the movw instruction on the enhanced core.
** If too many, those that don't fit are passed on the stack.
** 
** Return values: 
** ==============
** 8-bit 			in r24 (not r25!), 
** 16-bit 			in r25:r24, 
** up to 32 bits 	in r22-r25, 
** up to 64 bits 	in r18-r25.
** 8-bit return values are zero/sign-extended to 16 bits by the called function (unsigned char 
** is more efficient than signed char - just clr r25). Arguments to functions with variable argument 
** lists (printf etc.) are all passed on stack, and char is extended to int.
** 
** Warning:
** ========
** There was no such alignment before 2000-07-01, including the old patches for gcc-2.95.2. 
** Check your old assembler subroutines, and adjust them accordingly.
**
**	NOTE: This definitions are valid for GCC compiler only!!!
**
******************************************************************************/
#ifndef __RTOS_CTOASM_INC___
#define __RTOS_CTOASM_INC___

#define		Wl 		R24
#define		Wh 		R25
#define		Xl 		R26
#define		Xh 		R27
#define		Yl 		R28
#define		Yh 		R29
#define		Zl 		R30
#define		Zh 		R31

#define 	p1l     R24		
#define 	p1h     R25		
#define 	p2l     R22		
#define 	p2h     R23		

#define 	r1l     R24		
#define 	r1h     R25

#define 	tmp0    R18
#define 	tmp1    R19
#define 	tmp2    R20	  	
#define 	tmp3    R21
#define 	tmp4    R26   
#define 	tmp5    R27   

#endif /* __RTOS_CTOASM_INC___ */
